package com.Controller;

import com.Service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.entity.Class;
import java.util.List;

@RestController
@RequestMapping("/subject")
public class ClassController {
    @Autowired
    private ClassService classService;

    /**
     * 查询
     * @param cla
     * @return
     */
    @RequestMapping(value = "/queryClass",method = RequestMethod.GET)
    public List<Class> queryClass(Class cla){
        return classService.queryClass(cla);
    }

    /**
     * 新增
     * @param cla
     * @return
     */
    @RequestMapping(value = "/addClass",method = RequestMethod.POST)
    public int addClass(@RequestBody Class cla){
        return classService.addClass(cla);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delClass/{id}",method = RequestMethod.DELETE)
    public int delClass(@PathVariable int id){
        return classService.delClass(id);
    }

    /**
     * 修改
     * @param cla
     * @return
     */
    @RequestMapping(value = "/updateClass/{id}",method = RequestMethod.PUT)
    public int updateClass(@RequestBody Class cla,@PathVariable int id){
        cla.setClassId(id);
        return classService.updateClass(cla);
    }
}
